package cn.com.controller;

import cn.com.pojo.Merchant;
import cn.com.pojo.User;
import cn.com.service.MerchantService;
import cn.com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class PathController {
    @GetMapping("/")
    public String index(){

        return "index";
    }
    @GetMapping("/submit.html")
    public String submit(){
        return "submit";
    }
    @GetMapping("/login.html")
    public String login(){
        return "login";
    }
    @GetMapping("/shopSubmit.html")
    public String shopSubmit(){
        return "shopSubmit";
    }
    @GetMapping("/admin")
    public String admin(){
        return "admin";
    }
    @GetMapping("/admin-user")
    public String admin_user(){
        return "admin-user";
    }
    @GetMapping("/admin-merchant-apply")
    public String admin_merchant_apply(){
        return "admin-merchant-apply";
    }
    @GetMapping("/shop")
    public String shop(){
        return "shop";
    }

    @GetMapping("/logout")
    public String out(HttpSession session){
        session.removeAttribute("USER");
        return "index";
    }
    @Autowired
    MerchantService merchantService;
    @GetMapping("/user.html")
    public String user(String shopName, Model model){
        Merchant merchant=merchantService.showOne(shopName);
        model.addAttribute("shop",merchant);
        return "user";
    }
    @GetMapping("/user")
    public String user(){
        return "user";
    }
    @GetMapping("/a.html")
    public String a(){
        return "a";
    }
    @GetMapping("/b.html")
    public String b(){
        return "b";
    }
}
